Split String

 

 


string s = "Hello my; name"

string sub = ";"

int offset

int len

if ( findPlainText(s, sub, offset, len, false)) {


print s[0 : offset -1]

print s[offset +1 :]


} else {

print "Failed to match"

}

sa14 - Mon Feb 02 03:26:41 EST 2015

Re: Split String
Mathias Mamsch - Mon Feb 02 04:14:04 EST 2015

Well you need to loop your code .... Hope this helps. Regards, Mathias

string s = "Hello my; name;is;very;very;unusual"

string sub = ";"

int offset = 0, len = 0


while ( findPlainText(s, sub, offset, len, false)) {

    print s[0 : offset -1] "\n"   // print the part before the separator

    s = s[offset+1:]
} 

print s "\n"  // print the rest of the string

Re: Split String
sa14 - Mon Feb 02 04:53:07 EST 2015

Mathias Mamsch - Mon Feb 02 04:14:04 EST 2015

Well you need to loop your code .... Hope this helps. Regards, Mathias

string s = "Hello my; name;is;very;very;unusual"

string sub = ";"

int offset = 0, len = 0


while ( findPlainText(s, sub, offset, len, false)) {

    print s[0 : offset -1] "\n"   // print the part before the separator

    s = s[offset+1:]
} 

print s "\n"  // print the rest of the string

Hi, I get this error message: Array limit exceeded

 


while ( findPlainText(str, sub, offset, len, false)) {
string a[]={};

  a[y]=str[0 : offset -1]            //this line
   y = y+1
  str = str[offset+1:]
 

 
 

Re: Split String
Mathias Mamsch - Mon Feb 02 04:58:14 EST 2015

sa14 - Mon Feb 02 04:53:07 EST 2015

Hi, I get this error message: Array limit exceeded

 


while ( findPlainText(str, sub, offset, len, false)) {
string a[]={};

  a[y]=str[0 : offset -1]            //this line
   y = y+1
  str = str[offset+1:]
 

 
 

Of course you get it. You are defining an empty array. Check out the chapter about arrays inside the DXL manual. You may want to use a Skip list though. Regards, Mathias